#include "Poki.h"

void Poki::setup_app()
{
  is_running_app = true;
  switch (now_app)
  {
      case 0: app0 = new APP0; break;
      case 1: app1 = new APP1; break;
      case 2: app2 = new APP2; break;
      case 3: app3 = new APP3; break;
      case 4: app4 = new APP4; break;
      case 5: app5 = new APP5; break;
      case 6: app6 = new APP6; break;
      case 7: app7 = new APP7; break;
      case 8: app8 = new APP8; break;
      case 9: app9 = new APP9; break;
      case 10: app10 = new APP11; break;
      case 11: app11 = new APP11; break;
      case 12: app12 = new APP12; break;
  }
}
void Poki::run_app()
{
  switch (now_app)
  {
      case 0: cur_event = app0->main_process(cur_act); break;
      case 1: cur_event = app1->main_process(cur_act); break;
      case 2: cur_event = app2->main_process(cur_act); break;
      case 3: cur_event = app3->main_process(cur_act); break;
      case 4: cur_event = app4->main_process(cur_act); break;
      case 5: cur_event = app5->main_process(cur_act); break;
      case 6: cur_event = app6->main_process(cur_act); break;
      case 7: cur_event = app7->main_process(cur_act); break;
      case 8: cur_event = app8->main_process(cur_act); break;
      case 9: cur_event = app9->main_process(cur_act); break;
      case 10: cur_event = app10->main_process(cur_act); break; 
      case 11: cur_event = app11->main_process(cur_act); break; 
      case 12: cur_event = app12->main_process(cur_act); break; 
  }
}

void Poki::kill_app()
{
  switch (now_app)
  {
      case 0: delete app0; break;
      case 1: delete app1; break;
      case 2: delete app2; break;
      case 3: delete app3; break;
      case 4: delete app4; break;
      case 5: delete app5; break;
      case 6: delete app6; break;
      case 7: delete app7; break;
      case 8: delete app8; break;
      case 9: delete app9; break;
      case 10: delete app10; break;
      case 11: delete app11; break;
      case 12: delete app12; break;
  }
  is_running_app = false;
  lv_scr_load(app_scr);
  lv_label_set_text(now_app_label, app_name[now_app]);
  lv_obj_align(now_app_label, NULL, LV_ALIGN_CENTER, 0, 90);
  name_hidden = false;
  lv_obj_fade_in(now_app_icon, 500, 0);
  lv_obj_fade_in(now_app_label, 500, 0);
  lv_task_handler();
  name_hidden_time = millis();
}